package com.xmx.ndmalladmin.controller;

import java.util.Arrays;
import java.util.Map;

//import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
import io.swagger.annotations.ApiOperation;
import com.xmx.ndmalladmin.entity.UserTokenEntity;
import com.xmx.ndmalladmin.service.UserTokenService;
import com.xmx.common.utils.PageUtils;
import com.xmx.common.utils.R;
import io.swagger.annotations.Api;


/**
 * 系统用户Token
 *
 * @author fbb
 * @email boyinbing@126.com
 * @date 2021-08-11 01:54:35
 */
@Api(tags = "UserTokenController", description = "系统用户Token服务")
@RestController
@RequestMapping("ndmalladmin/usertoken")
public class UserTokenController {
    @Autowired
    private UserTokenService userTokenService;

    /**
     * 列表
     */
    @GetMapping("/list")
    //@RequiresPermissions("ndmalladmin:usertoken:list")
    @ApiOperation("获取所有系统用户Token信息")
    public R list(@RequestParam Map<String, Object> params){
        PageUtils page = userTokenService.queryPage(params);

        return R.ok().put("page", page);
    }


    /**
     * 信息
     */
    @GetMapping("/info/{userId}")
    //@RequiresPermissions("ndmalladmin:usertoken:info")
    @ApiOperation("获取指定id的系统用户Token详情")
    public R info(@PathVariable("userId") Long userId){
		UserTokenEntity userToken = userTokenService.getById(userId);

        return R.ok().put("userToken", userToken);
    }

    /**
     * 保存
     */
    @PostMapping("/save")
    @ApiOperation("添加系统用户Token信息")
    //@RequiresPermissions("ndmalladmin:usertoken:save")
    public R save(@RequestBody UserTokenEntity userToken){
		userTokenService.save(userToken);

        return R.ok();
    }

    /**
     * 修改
     */
    @PutMapping("/update")
    @ApiOperation("更新指定id系统用户Token信息")
    //@RequiresPermissions("ndmalladmin:usertoken:update")
    public R update(@RequestBody UserTokenEntity userToken){
		userTokenService.updateById(userToken);

        return R.ok();
    }

    /**
     * 删除
     */
    @DeleteMapping("/delete")
    @ApiOperation("删除指定id系统用户Token信息")
    //@RequiresPermissions("ndmalladmin:usertoken:delete")
    public R delete(@RequestBody Long[] userIds){
		userTokenService.removeByIds(Arrays.asList(userIds));

        return R.ok();
    }

}
